package com.ws.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ws.bean.RenralOrder;
import com.ws.bean.ReturnCheck;
import com.ws.common.CommonResult;
import com.ws.service.ReturnCheckService;
import com.ws.util.Page;

@RestController
@RequestMapping("check")
public class ReturnCheckController {
	@Autowired
	ReturnCheckService service;
	@GetMapping("select")
	public CommonResult getChecks(ReturnCheck check , Page page) {
		List<ReturnCheck> list = service.getChecks(check,page);
		int count = service.getCount(check);
		Map map = new HashMap<>();
		map.put("list", list);
		map.put("count", count);
		return CommonResult.success(map);
		}
	@PostMapping("add")
	public CommonResult addCheck(@RequestBody ReturnCheck check) {
		int result = service.addCheck(check);
		return CommonResult.success();
	}
	@DeleteMapping("del/{id}")
	public CommonResult delCheck(@PathVariable Integer id) {
		int result = service.delCheck(id);
		return CommonResult.success();
	}
	@PutMapping("edit")
	public CommonResult editCheck(ReturnCheck check) {
		int result = service.editCheck(check);
		return CommonResult.success();
	}
	@GetMapping("getorders")
	public CommonResult getOrders() {
		List<RenralOrder> list = service.getOrders();
		return CommonResult.success(list);
	}
}
